package trading_strategy.events;

import trading_strategy.orders.OrderSign;

/**
 * Created by IntelliJ IDEA.
 * User: gderoujoux
 * Date: 6 mai 2010
 * Time: 10:43:26
 * To change this template use File | Settings | File Templates.
 */
public class OrderBook {
    double[] bids;
    int[] bidQtys;
    double asks[];
    int askQtys[];
    int bidDepth;
    int askDepth;

    public OrderBook(int bidDepth, double[] bids, int[] bidQtys, int askDepth, double[] asks, int[] askQtys) {
        this.bidDepth = bidDepth;
        this.bids = bids;
        this.bidQtys = bidQtys;
        this.askDepth = askDepth;
        this.asks = asks;
        this.askQtys = askQtys;
    }

    public OrderBook() {
    }

    public double getBid(int level) {
        if (level >= bidDepth) {
            return Double.NaN;
        }
        return bids[level];
    }

    public double getAsk(int level) {
        if (level >= askDepth) {
            return Double.NaN;
        }
        return asks[level];
    }

    public int getBidQty(int level) {
        if (level >= bidDepth) {
            return 0;
        }
        return bidQtys[level];
    }
    public int getAskQty(int level) {
        if (level >= askDepth) {
            return 0;
        }
        return askQtys[level];
    }

    public double getPrice(int level, OrderSign sign) {
        switch (sign) {
            case ASK:
                return getAsk(level);
            case BID:
                return getBid(level);
        }
        return Double.NaN;
    }

    public double getQty(int level, OrderSign sign) {
        switch (sign) {
            case ASK:
                return getAskQty(level);
            case BID:
                return getBidQty(level);
        }
        return 0;
    }

    public int getBidDepth() {
        return bidDepth;
    }

    public int getAskDepth() {
        return askDepth;
    }
}
